<?php
/*
 * @copyright        [YouNet_COPYRIGHT]
 * @author           YouNet Development
 * @package          Module_Contactimporter
 * @version          2.06
 *
 */
defined('PHPFOX') or exit('NO DICE!');
?>

<?php
class Contactimporter_Component_Block_Monthly_Top_inviter extends Phpfox_Component
{
    public function process()
    {
		$sCurrentTimeZone = date_default_timezone_get();
		date_default_timezone_set(PHPFOX_SERVER_TIME_ZONE);
		$sConds  = ' pi.year = ' . date('Y');
		$sConds .= ' AND pi.month = ' . date('n');
		$sConds .= ' AND pi.total > 0';
		date_default_timezone_set($sCurrentTimeZone);
		$sLimit = 10;
        $topinviter =  phpfox::getLib('phpfox.database')->select('pu.user_name,pi.user_id,pu.full_name,pu.email as inviter_email,pi.total')
			->from(phpfox::getT('contactimporter_statistics_monthly'),'pi')
			->leftJoin(phpfox::getT('user'),'pu','pu.user_id = pi.user_id')
			->group('pi.user_id')
			->where($sConds)
			->order('pi.total DESC')
			->limit($sLimit)
			->execute('getRows');
		if (!$topinviter) return false;
        $this->template()->assign(array(
			'sHeader' => Phpfox::getPhrase('contactimporter.monthly_top_inviters'),
            'sDeleteBlock' => 'dashboard',
			'Ynscontactimporter.css' => 'module_contactimporter',
			'jquery.min.js'=>'module_contactimporter',
			'contactimporter.js'=>'module_contactimporter',
			'aMonthlyTopInviter'=>$topinviter ,
		));
        return 'block';
    }
}
?>